package ro.qi.framework.sys.db.pool;


class ConnectionReaper extends Thread {

    private JDCConnectionPool pool;
    private long delay;
    public boolean running = false;

    ConnectionReaper(JDCConnectionPool pool, long delay) {
    	super("ConnectionReaper_For_Database");
        this.delay = delay;
        this.pool=pool;
    }

    public void run() {
		running = true;
        while(running) {
           try {
              sleep(delay);
           } catch( InterruptedException e) { }
            long start = System.currentTimeMillis();
            pool.reapConnections();
            long length = System.currentTimeMillis() - start;
            // if ( length > 1000 ) Logger.info("ConnectionReaper.run() reapConnections() took: " + length + " millis" );
        }
    }
}
